<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .nav{
            margin: 100px;
            /* border: 1px solid black; */
            
        }
        .nav li{
            width: 90px;
            /* height: 40px; */
            float: left;
            list-style-type: none;
            text-align: center;
            position: relative;
            /* background-color: aqua; */
            /* border: 1px solid black; */
            /* padding: 20px 0; */
        }
        .nav li a{
            display: block;
            width: 100%;
            /* height: 100%; */
            line-height: 40px;
            text-decoration: none;
            background-color: pink;
            font-size: 14px;
            color: #333;
        }
        .nav li a:hover{
            background-color: #eee;
        }
        .nav li ul{
            /* border: 1px solid black; */
            display: none;
            position: absolute;
            top: 40px;
            left: 0;
            width: 100%;
        }
        .nav ul li a:hover{
            background-color: #FFF5DA;
        }
    </style>
</head>
<body>
    <ul class="nav">
        <li>
            <a href="#">微博</a>
            <ul>
                <li>
                    <a href="">私信</a>
                </li>
                <li>
                    <a href="">评论</a>
                </li>
                <li>
                    <a href="">@我</a>
                </li>
            </ul>
        </li>
        <li>
            <a href="#">微博</a>
            <ul>
                <li>
                    <a href="">私信</a>
                </li>
                <li>
                    <a href="">评论</a>
                </li>
                <li>
                    <a href="">@我</a>
                </li>
            </ul>
        </li>
        <li>
            <a href="#">微博</a>
            <ul>
                <li>
                    <a href="">私信</a>
                </li>
                <li>
                    <a href="">评论</a>
                </li>
                <li>
                    <a href="">@我</a>
                </li>
            </ul>
        </li>
        <li>
            <a href="#">微博</a>
            <ul>
                <li>
                    <a href="">私信</a>
                </li>
                <li>
                    <a href="">评论</a>
                </li>
                <li>
                    <a href="">@我</a>
                </li>
            </ul>
        </li>
    </ul>
    <script>
        // 1. 获取元素
        var nav = document.querySelector('.nav');
        var lis = nav.children;// 得到4个小li
        // 2.循环注册事件
        for(var i = 0; i < lis.length; i++){
            lis[i].onmouseover = function(){
                this.children[1].style.display = 'block';
            }
            lis[i].onmouseout = function(){
                this.children[1].style.display = 'none';
            }
        }

    </script>
</body>
</html>